package packet

import (
	"encoding/hex"
	"hy_808/protocol/hygprs"
	"strings"
	"time"
)

type DDClientLogin struct {
	hygprs.Fields
}

func GenDDClientLogin(line, bus int) (p DDClientLogin) {
	data, _ := hex.DecodeString(strings.ReplaceAll("a0 01 47 02 00 01 a2 01 00 00 00 01 02 00 0e cb e0 f1 00 00 00 01 f1 00 00 00 02 00 00 55 9f a1", " ", ""))
	dd := DDClientLogin{hygprs.MakeFields(hygprs.MakePacket(data))}
	dd.SetLineID(uint32(line))
	dd.SetBusID(uint32(bus))
	dd.SetUnix(uint32(time.Now().Local().Unix()))

	//查询所有线路
	//DB := di.TakeDB()
	//logger := di.Logdot()
	//rows, err := DB.Query(`SELECT LINE_NO FROM UPGRADE_LINE`)
	//if err != nil {
	//	logger.Error("查询所有监听线路失败", err)
	//	return DDClientLogin{}
	//}
	////设置监听线路
	//var lineList []uint32
	//for _, row := range rows {
	//	lineList = append(lineList, uint32(row.Get("LINE_NO").Int()))
	//}
	//dd.SetBytesAppend(0xf1, lineList)
	dd.Pack()
	return dd
}
